# OBS服务已注释 - 使用本地存储替代
# from obs import ObsClient
# from typing import BinaryIO
# from config.settings import config


# class OBSService:
#     """华为云 OBS 服务"""

#     def __init__(self):
#         """初始化 OBS 服务"""
#         self._client = None

#     @property
#     def client(self) -> ObsClient:
#         if self._client is None:
#             self._client = ObsClient(
#                 access_key_id=config.HUAWEICLOUD_ACCESS_KEY,
#                 secret_access_key=config.HUAWEICLOUD_SECRET_KEY,
#                 server=config.HUAWEICLOUD_OBS_ENDPOINT,
#             )
#         return self._client

#     def upload_file(
#         self, file_data: BinaryIO, object_key: str, content_type: str | None = None
#     ) -> str:
#         """上传文件到华为云 OBS

#         Args:
#             file_data: 文件数据流
#             object_key: 对象键（文件在 OBS 中的路径）
#             content_type: 文件内容类型，例如 'image/jpeg'

#         Returns:
#             str: 文件的访问 URL
#         """
#         try:
#             resp = self.client.putObject(
#                 bucketName=config.HUAWEICLOUD_OBS_BUCKET,
#                 objectKey=object_key,
#                 content=file_data,
#                 metadata={"Content-Type": content_type} if content_type else None,
#             )

#             if resp.status < 300:
#                 # 上传成功，返回文件访问 URL
#                 return f"{config.HUAWEICLOUD_OBS_CDN_ENDPOINT}/{object_key}"
#             else:
#                 raise Exception(f"Failed to upload file to OBS: {resp.errorMessage}")
#         except Exception as e:
#             raise Exception(f"Failed to upload file to OBS: {str(e)}")

#     def __del__(self):
#         if self._client:
#             self._client.close()
